var $table = $('#table'), $button = $('#button');
var zTree, rMenu;
$(function() {
	getTree();
});
function getTree() {
	$.ajax({
			url : RS.webPath + '/admin/rsOrgan/queryTree',
			type : 'get',
			dataType : 'json',
			success : function(ret) {
				zTree = $.fn.zTree.init($("#organTree"), setting, ret);
				rMenu = $("#rMenu");
				zTree.expandAll(true);
			}
	});

}

function save() {
	var treeObj = $.fn.zTree.getZTreeObj("organTree");
	var nodes = treeObj.getCheckedNodes(true);
	if(nodes.length<=0){
		parent.layer.alert("请选择该用户所在的机构");
		return;
	}
	var organId = nodes[0].id;
	$.ajax({
			url : RS.webPath + '/admin/user/editUserOrgan?userId=' + uid + "&organId=" + organId,
			type : 'post',
			success : function(ret) {
				if (ret > 0) {
					parent.layer.alert('提交成功', function(index) {
						parent.layer.closeAll();
					});
				} else {
					parent('提交失败');
				}
			},
			error : function() {
				parent('提交失败');
			}

	});

}

function closeAll() {
	parent.layer.closeAll();
}